package com.findu.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.view.Window;
import android.widget.ImageButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;

import com.example.findu.R;
import com.findu.control.Public_title;
import com.findu.fragment.Fragment_Conversaction_dynamic_4;
import com.findu.fragment.Fragment_Conversaction_genealogy_3;
import com.findu.fragment.Fragment_Conversaction_relatives_2;
import com.findu.fragment.Fragment_Conversation_More_5;
import com.findu.fragment.Fragment_Conversation_home_1;

public class Conversation_home extends FragmentActivity implements
		OnCheckedChangeListener {

	// 定义一个碎片管理器
	private FragmentManager fragmentManager;

	// 声明Tittle控件
	private ImageButton imageButton_left, imageButton_right;
	private TextView textView_title;
	Public_title public_title; // 标题控制

	// 声明布局文件
	private View include_view;

	// 声明主页底部选项卡控件
	private RadioGroup activity_first_radioGroup;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_conversation_home);

		// 初始化主页底部选项卡控件
		activity_first_radioGroup = (RadioGroup) findViewById(R.id.activity_conversation_radioGroup);
		// 绑定监听事件
		activity_first_radioGroup.setOnCheckedChangeListener(this);

		// 初始化碎片管理器
		fragmentManager = getSupportFragmentManager();
		fragmentManager
				.beginTransaction()
				.replace(R.id.activity_conversation_frameLayout,
						new Fragment_Conversation_home_1()).commit();
		// 初始化碎片
	}

	@Override
	public void onCheckedChanged(RadioGroup arg0, int arg1) {
		// TODO Auto-generated method stub
		switch (arg1) {
		case R.id.activity_conversation_radioButton1:
			fragmentManager
			.beginTransaction()
			.replace(R.id.activity_conversation_frameLayout,
					new Fragment_Conversation_home_1()).commit();
			break;
		case R.id.activity_conversation_radioButton2:
			fragmentManager
			.beginTransaction()
			.replace(R.id.activity_conversation_frameLayout,
					new Fragment_Conversaction_relatives_2()).commit();
			break;
		case R.id.activity_conversation_radioButton3:
			fragmentManager
			.beginTransaction()
			.replace(R.id.activity_conversation_frameLayout,
					new Fragment_Conversaction_genealogy_3()).commit();
			break;
		case R.id.activity_conversation_radioButton4:
			fragmentManager
			.beginTransaction()
			.replace(R.id.activity_conversation_frameLayout,
					new Fragment_Conversaction_dynamic_4()).commit();
			break;
		case R.id.activity_conversation_radioButton5:
			fragmentManager
			.beginTransaction()
			.replace(R.id.activity_conversation_frameLayout,
					new Fragment_Conversation_More_5()).commit();
			break;

		default:
			break;
		}
	}
	
  /**
   * 
   * @author ggj 
   * 跳转到当前页面
   * 参考资料http://blog.csdn.net/kroclin/article/details/47724283#comments
   */
	public static void start(Context context){
        Intent intent = new Intent(context, Conversation_home.class);
        context.startActivity(intent);
    }
}
